#这题考查列表list的应用，相对比较基础


n, m = map(int, input().split())
cs= []
for _ in range(n):
    row = list(map(int, input().split()))
    cs.append(row)
new = [[0 for _ in range(n)] for _ in range(m)]
for i in range(n):
    for j in range(m):
        new[j][n - i - 1]=cs[i][j]
for row in new:
    for num in row:
        print(num, end=' ')
    print()